import { request } from "vendor/utils/T";
import { toApi } from "@/service/proxyApi";
import { RequestDataType, RespDataType} from "./apiType";
export * from "./apiType";

const {get, postJSON, del, put, mockRespData } = request;

/**
 * 获取数据集分页列表
 */
export const getDataSetPageList = (params: {page:number, pageSize: number}) => {
    // return get<RespDataType.DataSetPageList>(toApi("project/list"), params);

    return mockRespData<RespDataType.DataSetPageList>({
        total: 10,
        list: new Array(10).fill(0).map((_, index) => ({
            id: index.toString(),
            name: "test-" + (index + 1),
            createBy: "test",
            updateBy: "",
            createTime: "2022-04-11 11:11:11",
            updateTime: "2022-04-11 11:11:11",
        }))
    });
}

/**
 * 创建数据集
 */
export const createDataSet = (params:RequestDataType.CreateDataSetItem) => {
    // return postJSON(toApi("project"), params);
    return mockRespData("");
}

/**
 * 获取数据集信息
 */
export const getDataSetInfo = (dataSetId: number) => {
    // return get<RespDataType.DataSetItem>(toApi("project"), {dataSetId});
    return mockRespData<RespDataType.DataSetItem>({
        id: "1",
        name: "test-1",
        createBy: "test",
        updateBy: "",
        createTime: "2022-04-11 11:11:11",
        updateTime: "2022-04-11 11:11:11",
    });
}

/**
 * 更新数据集信息
 */
export const updateDataSet = (dataSetId: number, params:Partial<RequestDataType.UpdateDataSetItem>) => {
    // return put(toApi(`project?dataSetId=${dataSetId}`), params);
    return mockRespData("");
}

/**
 * 删除数据集信息
 */
export const deleteDataSet = (dataSetIds:number[]) => {
    // return del(toApi(`project`), {ids: dataSetIds});
    return mockRespData("");
}

